package com.lgd.design.service.strategy;

import com.lgd.design.enums.BusinessType;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 业务类创建工厂
 */
@Service
public class ServiceFactory {

    @Resource
    private ServiceOne serviceOne;
    @Resource
    private ServiceTwo serviceTwo;
    @Resource
    private DefaultService defaultService;

    public AbstractService getServiceByBusinessType(BusinessType businessType) {
        switch (businessType) {
            case BUSINESS_01:
                return serviceOne;
            case BUSINESS_02:
                return serviceTwo;
            default:
                return defaultService;
        }
    }

}
